package top.drinyeit.weilong.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import org.json.JSONException;
import org.json.JSONObject;

import java.text.SimpleDateFormat;
import java.util.Date;

import top.drinyeit.weilong.R;
import top.drinyeit.weilong.base.BaseActivity;

/**
 * Created by Administrator on 2018/2/9.
 */

public class PaySuccessActivity extends BaseActivity{
    public TextView storeName,money,date,back;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pay_success);

        initView();
        initIntent();
    }

    private void initView(){
        storeName = findViewById(R.id.tv_store_name);
        money = findViewById(R.id.tv_money);
        date = findViewById(R.id.tv_date);
        back = findViewById(R.id.tv_back);
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    private void initIntent(){
        if (getIntent() == null){
            showToast("错误,请重新操作");
        }else {
            storeName.setText("商户名称:" + getIntent().getExtras().getString("store_name"));
            money.setText("金额:" + getIntent().getExtras().getString("money"));
            date.setText(getNowTime());
        }
    }

    /**
     * 获取当前时间
     * @return
     */
    public static String getNowTime(){
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
        Date date = new Date(System.currentTimeMillis());
        return simpleDateFormat.format(date);
    }
}
